package com.lin.subject.application.controller;

import com.lin.auth.entity.Result;
import com.lin.subject.commom.entity.PageResult;
import com.lin.subject.infra.basic.entity.SubjectInfoEs;
import com.lin.subject.infra.basic.service.SubjectEsService;
import com.lin.subject.infra.entity.UserInfo;
import com.lin.subject.infra.rpc.UserRpc;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 刷题分类controller
 *
 * @author: ChickenWing
 * @date: 2023/10/1
 */
@RestController
@RequestMapping("/feign")
@Slf4j
public class TestFeignController {

    @Resource
    private SubjectEsService subjectEsService;

    @Resource
    private UserRpc userRpc;

    @GetMapping("testFeign")
    public Result<UserInfo> testFeign() {
        UserInfo userInfo = userRpc.getUserInfo("oqGgu6rd_qN0igb4_z9_YLYWJkI4");
        log.info("testFeign.userInfo:{}", userInfo);
        return Result.ok(userInfo);
    }

    @GetMapping("testEsSearch")
    public Result<PageResult<SubjectInfoEs>> testEsSearch() {
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyWord("mysql");
        subjectInfoEs.setPageNo(1);
        subjectInfoEs.setPageSize(10);
        PageResult<SubjectInfoEs> subjectInfoEsPageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("testFeign.testEsSearch:{}", subjectInfoEsPageResult);
        return Result.ok(subjectInfoEsPageResult);
    }



//    @GetMapping("testCreateIndex")
//    public void testCreateIndex() {
//        subjectEsService.createIndex();
//    }
//
//    @GetMapping("addDocs")
//    public void addDocs() {
//        subjectEsService.addDoc();
//    }
//
//    @GetMapping("find")
//    public void find() {
//        subjectEsService.find();
//    }
//
//    @GetMapping("search")
//    public void search() {
//        subjectEsService.search();
//    }
}
